//
//  CommentInfo.m
//  TodayComment
//
//  Created by 张吉阳 on 15/9/12.
//  Copyright (c) 2015年 xianrenmoshi. All rights reserved.
//

#import "CommentInfo.h"

@implementation CommentInfo
+ (CommentInfo *)infoFromDict:(NSDictionary *)dict
{
    CommentInfo *info = [[CommentInfo alloc] init];
    info.ID = [dict valueForKey:@"pi"];
    info.name = [dict valueForKey:@"n"];
    info.address = [dict valueForKey:@"f"];
    info.commentCount = [dict valueForKey:@"v"];
    info.date = [dict valueForKey:@"date"];
    info.commentContent = [dict valueForKey:@"b"];
    info.iconImage = [dict valueForKey:@"iconUrl"];
    info.headImage = [dict valueForKey:@"timg"];
    info.boardid = [dict valueForKey:@"boardid"];
    info.json = [FxJsonUtility jsonValueFromObject:dict];
    return info;
}

+ (NSArray *)arrayFromDict:(NSDictionary *)dict
{
    
    NSArray *array = [dict valueForKey:@"hotPosts"];
    return [[self class] arrayFromArray:array];
    
}

+ (NSArray *)arrayFromArray:(NSArray *)array
{
    NSMutableArray  *infos = [[NSMutableArray alloc]init];
    if ([array isEqual:[NSNull null]]) {
        return nil;
    }
    for (NSDictionary *dict in array) {
        [infos addObject:[[self class] infoFromDict:[dict valueForKey:@"1"]]];
    }
    if(infos.count > 0) {
        return infos;
    }
    else{
        return nil;
    }
}

@end
